package kernel;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class ROI2D {
	private ROI roi_i;
	private ROI roi_j;
	private Set<Fiber> fibers;
	
	
	public ROI2D(ROI roi_i, ROI roi_j)
	{
		this.roi_i = roi_i;
		this.roi_j = roi_j;
		fibers = new HashSet<Fiber>();
	}
	
	public void calculateFibers()
	{
		Map<Fiber, Integer> roi_i_fibers = roi_i.getFibers();
		Map<Fiber, Integer> roi_j_fibers = roi_j.getFibers();
		
		if(roi_i_fibers.size() >= roi_j_fibers.size())
		{
			for(Map.Entry<Fiber, Integer> entry : roi_i_fibers.entrySet())
			{
				
				Fiber f = entry.getKey();
				if(roi_j_fibers.containsKey(f))
				{
					fibers.add(f);
				}
			}
		}
		else
		{
			for(Map.Entry<Fiber, Integer> entry : roi_j_fibers.entrySet())
			{
				Fiber f = entry.getKey();
				if(roi_i_fibers.containsKey(f))
				{
					fibers.add(f);
				}
			}
		}
		
		
	}

	/**
	 * @return the roi_i
	 */
	public ROI getRoi_i() {
		return roi_i;
	}

	/**
	 * @return the roi_j
	 */
	public ROI getRoi_j() {
		return roi_j;
	}

	/**
	 * @return the fibers
	 */
	public Set<Fiber> getFibers() {
		return fibers;
	}
	
	

}
